package hashmap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : HashMapDemo2
 * @Author : 54061
 * @Date: 2022/2/9 16:26
 */
public class HashMapDemo2 {
    public static void main(String[] args) {
        //创建集合对象
        HashMap<String,String> hm = new HashMap<>();
        System.out.println("hm = " + hm);


        //添加元素
        hm.put("段延庆" , "大理王妃");
        hm.put("少林方丈" , "叶二娘");
        hm.put("尹志平" , "小龙女");
        System.out.println("hm = " + hm);

        Set<Map.Entry<String, String>> entries = hm.entrySet();

        for (Map.Entry<String,String> entry : entries){
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key  + value);
        }
    }
}
